<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../../../v2/common/jspcommon.jsp"%>
<%@include file="../../common/jscss.jsp"%>
<script src="/thirdparty/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<style>
	a.fl {position:relative;overflow:hidden;status:inline-block;color:#005197;text-decoration:underline;vertical-align:bottom;*vertical-align:auto}
	a.fl input {position:absolute;right:0;top:0;height:100px;opacity:0;filter:alpha(opacity=0);cursor:pointer;cursor:hand}
	a.fl:hover {color:#f65100}
	#files{font:normal 14px/16px "微软雅黑";margin:10px;}
	#files a{margin:0 20px 0 10px; font-size:14px;}
	.l-table-edit {font-size: 12px;margin: auto;}
 	.l-table-edit-td{ padding:4px;}
    .l-button-submit,.l-button-test{width:80px; float:left; margin-left:10px; padding-bottom:2px;}
    .l-verify-tip{ left:230px; top:120px;}
    .error{color:red}
</style>

<form action="/misc/top/savetopshop.htm" method="post" id="form">
	<input type="hidden" name="identifier" value="${identifier }"/>
	<input type="hidden" name="saveType" value="${saveType }"/>
	<table cellpadding="0" cellspacing="0" class="l-table-edit">
	  <tr>
	    <td class="l-table-edit-td">卖家ID：</td>
	    <td class="l-table-edit-td"><input type="text" name="sellerId" value="${taobaokeShop.sellerId }" width="220px"/></td>
	  </tr>
	  <tr>
	    <td class="l-table-edit-td">店铺名：</td>
	    <td class="l-table-edit-td"><input type="text" name="shopName" value="${taobaokeShop.shopName }" width="220px"/></td>
	  </tr>
	  <tr>
	    <td class="l-table-edit-td">描述：</td>
	    <td class="l-table-edit-td">
	    	<textarea cols="100" style="width: 300px;height: 100px;resize:none;" class="l-textarea" name="description" id="description">${taobaokeShop.description }</textarea>
	    </td>
	  </tr>
	  <tr>
	    <td class="l-table-edit-td">店铺网址：</td>
	    <td class="l-table-edit-td">
	    	<textarea cols="20" style="width: 300px;height: 30px;resize:none;" class="l-textarea" name="website" id="website">${taobaokeShop.website }</textarea>
	    </td>
	  </tr>
	  <tr>
	    <td class="l-table-edit-td">logo：</td>
	    <td class="l-table-edit-td">
	    	<div id="logo_div">
	    		<img id="logo_image" width="80" height="80" src="${taobaokeShop.logo }"/>
	    	</div>
	    	<a href="javascript:void(0)" id="a_logo" >上传logo</a>
	    	<input type="hidden" id="logo" name="logo" value="${taobaokeShop.logo }"/>
	    </td>
	  </tr>
	  <tr>
	  	<td class="l-table-edit-td" colspan="2">
	  		<input type="submit" value="保存" id="btnSend" />
	  	</td>
	  </tr> 
	</table>
	
</form>

<form id="logoUpload" action="/misc/top/uploadlogo.htm" method="post" enctype="multipart/form-data">
	<input type="file" name="logoUploadFile" id="logoUploadFile" onchange="uploadLogo();" style="display: none;"/>
	<input type="hidden" name="identifier" value="${identifier }"/>
</form>
<script type="text/javascript">
	$(function(){
		
		//表单验证
		$("#form").validate({
	        success: function (lable){
	           lable.ligerHideTip();
	           lable.remove();
	        },
	        rules:{
	        	sellerId:{required : true},
	        	shopName:{required : true},
	        	description:{required : true},
	        	logo:{required : true}
	        },
	        messages : {
	        	sellerId : {required : "请填卖家ID"},
	        	shopName : {required : "请填店铺名字"},
	        	description : {required : "请填写店铺描述"},
	        	logo : {required : "请上传封面logo"}
			},
			submitHandler : function(form) {
				 $(form).ajaxSubmit(function(data){
					 if(data=="success"){
						parent.grid_ae.loadData();
						parent.dialog_ae.close();
					 }
				 });
			}
		});
		$("#a_logo").click(function(e){
			e.preventDefault();
			$("#logoUploadFile").trigger('click');
		});
	});
	
function uploadLogo(){
	$("#logo").val("");
	var filepath=$("#logoUploadFile").val(); 
	if(filepath!=null && filepath!=""){
		var extStart=filepath.lastIndexOf("."); 
		var ext=filepath.substring(extStart,filepath.length).toUpperCase();
		if(ext!=".PNG"&&ext!=".JPG"&&ext!=".JPEG"){ 
			alert("图片限于png,jpeg,jpg格式"); 
			return ; 
		}
	}
	$("#logoUpload").ajaxSubmit({
		dataType : 'json',
		cache : false,
		success : function(data) {
			if(data.sizeAllow==true){
				var url=data.imageServer+data.imageUrl;
				alert("上传成功");
				$("#logo").val(url);
				$("#logo_div").html('<img id="logo_image" width="80" height="80" src="'+url+'"/>');
			}else{
				alert("照片大小不能超过2M!");
			}
		},
		error : function(err) {
			alert(err);
		}
	});
	return false;
}	
</script>